<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    <h2 @click="fy">store.name：{{$store.state.name}}</h2>
    <p>{{nameMsg}}</p>
    <p @click="increment()">store.count：{{$store.state.count}}</p>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      nameMsg:'',
      num:10
    }
  },
  created() {
    this.nameMsg=this.$store.getters.nameInfo
  },
  methods: {
    increment() {
      //this.$store.commit('increment',this.num)
      this.$store.commit({
        type:'increment',
        param:{
          num:this.num,
          age:15
        }
      })
    },
    fy(){
      this.$store.dispatch('changeName',{age:15,sex:'男'})
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
